<template>
  <div>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm">
      <el-form-item prop="username">
        <el-input placeholder="请输入用户名" v-model="ruleForm.username">
          <i slot="prefix" class="el-icon-user"></i>
        </el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input
          placeholder="请输入密码"
          v-model="ruleForm.password"
          show-password
          @keyup.enter="login"
        >
          <i slot="prefix" class="el-icon-lock"></i>
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          class="btn_login"
          style="width: 80%; margin: 5px 20px"
          @click="login"
          >登录</el-button
        >
        <el-button
          type="primary"
          class="btn_enroll"
          style="width: 80%; margin: 5px 20px"
          @click="enroll"
          >注册</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "AccountLogin",
  props: {
    ruleForm: {
      type: Object,
      require: true,
    },
    rules: {
      type: Object,
      require: true,
    },
  },
  methods: {
    login() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.$emit("submit");
        } else {
          this.$emit("errHandle");
        }
      });
    },
    enroll() {
      this.$router.push("/enroll");
    },
  },
  mounted() {},
};
</script>
<style scoped>
.el-radio {
  margin-right: 10px;
  color: white;
}
</style>
